|
|
@@ -143,10 +143,41 @@ public class DBService {
|
143
|
143
|
}
|
144
|
144
|
}
|
145
|
145
|
|
146
|
|
- public ArrayList<SessionBean> getSessionBeanListByDay(){
|
|
146
|
+ public ArrayList<SessionBean> getSessionBeanListByDay(long sessionDate){
|
147
|
147
|
ArrayList<SessionBean> sessionBeanArrayList = new ArrayList<>();
|
148
|
|
- //TODO
|
149
|
|
-
|
|
148
|
+ SQLiteDatabase db = null;
|
|
149
|
+ Cursor c = null;
|
|
150
|
+ synchronized (DB_LOCK) {
|
|
151
|
+ try {
|
|
152
|
+ db = dbHelper.getReadableDatabase();
|
|
153
|
+ db.beginTransaction();
|
|
154
|
+ c = db.rawQuery("select * from " + DBHelper.PHOTO_INFO_TABLE + " where "
|
|
155
|
+ + DBHelper.PHOTO_INFO_COLUMNS.SESSION_DATE + " = '" + sessionDate + "' order by " + DBHelper.PHOTO_INFO_COLUMNS.SESSION_SEQ + " desc", null);
|
|
156
|
+ while (c.moveToNext()) {
|
|
157
|
+ PhotoBean photoBean = cursor2PhotoBean(c);
|
|
158
|
+ if(sessionBeanArrayList.size()==0 || sessionBeanArrayList.get(sessionBeanArrayList.size()-1).sessionSeq!=photoBean.sessionSeq){
|
|
159
|
+ SessionBean sessionBean = new SessionBean();
|
|
160
|
+ sessionBean.sessionDate = photoBean.sessionDate;
|
|
161
|
+ sessionBean.sessionSeq = photoBean.sessionSeq;
|
|
162
|
+ sessionBean.sessionId = photoBean.sessionId;
|
|
163
|
+ ArrayList<PhotoBean> photoList = new ArrayList<>();
|
|
164
|
+ sessionBean.sessionPhotos = photoList;
|
|
165
|
+ sessionBeanArrayList.add(sessionBean);
|
|
166
|
+ }
|
|
167
|
+ sessionBeanArrayList.get(sessionBeanArrayList.size()-1).sessionPhotos.add(photoBean);
|
|
168
|
+ }
|
|
169
|
+ db.setTransactionSuccessful();
|
|
170
|
+ } catch (Exception e) {
|
|
171
|
+ LogHelper.d(TAG, "dbservice getSessionBeanListByDay error happen " + e);
|
|
172
|
+ } finally {
|
|
173
|
+ try {
|
|
174
|
+ db.endTransaction();
|
|
175
|
+ } catch (Exception e) {
|
|
176
|
+ e.printStackTrace();
|
|
177
|
+ }
|
|
178
|
+ closeCursorAndDB(c, db);
|
|
179
|
+ }
|
|
180
|
+ }
|
150
|
181
|
return sessionBeanArrayList;
|
151
|
182
|
}
|
152
|
183
|
|